home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.accessibility.Accessible;
- import com.sun.java.accessibility.AccessibleContext;
- import com.sun.java.accessibility.AccessibleState;
- import com.sun.java.swing.event.ChangeEvent;
- import com.sun.java.swing.event.ChangeListener;
- import com.sun.java.swing.event.EventListenerList;
- import com.sun.java.swing.plaf.ProgressBarUI;
- import java.awt.Component;
- import java.awt.Graphics;
-
- public class JProgressBar extends JComponent implements SwingConstants, Accessible {
- protected int orientation;
- protected boolean paintBorder;
- protected BoundedRangeModel barModel;
- protected transient ChangeEvent changeEvent = null;
- protected ChangeListener changeListener = null;
- static Class class$com$sun$java$swing$event$ChangeListener;
-
- public JProgressBar() {
- this.setModel(new DefaultBoundedRangeModel());
- this.updateUI();
- this.orientation = 0;
- this.paintBorder = true;
- }
-
- public void addChangeListener(ChangeListener l) {
- EventListenerList var10000 = super.listenerList;
- Class var10001 = class$com$sun$java$swing$event$ChangeListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$com$sun$java$swing$event$ChangeListener = var10001;
- }
-
- var10000.add(var10001, l);
- }
-
- protected ChangeListener createChangeListener() {
- return new ModelListener(this);
- }
-
- protected void fireStateChanged() {
- Object[] listeners = super.listenerList.getListenerList();
-
- for(int i = listeners.length - 2; i >= 0; i -= 2) {
- Object var10000 = listeners[i];
- Class var10001 = class$com$sun$java$swing$event$ChangeListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
- } catch (ClassNotFoundException var3) {
- throw new NoClassDefFoundError(((Throwable)var3).getMessage());
- }
-
- class$com$sun$java$swing$event$ChangeListener = var10001;
- }
-
- if (var10000 == var10001) {
- if (this.changeEvent == null) {
- this.changeEvent = new ChangeEvent(this);
- }
-
- ((ChangeListener)listeners[i + 1]).stateChanged(this.changeEvent);
- }
- }
-
- }
-
- public AccessibleContext getAccessibleContext() {
- if (super.accessibleContext == null) {
- super.accessibleContext = new AccessibleJProgressBar(this);
- }
-
- return super.accessibleContext;
- }
-
- public int getMaximum() {
- return this.getModel().getMaximum();
- }
-
- public int getMinimum() {
- return this.getModel().getMinimum();
- }
-
- public BoundedRangeModel getModel() {
- return this.barModel;
- }
-
- public int getOrientation() {
- return this.orientation;
- }
-
- public ProgressBarUI getUI() {
- return (ProgressBarUI)super.ui;
- }
-
- public String getUIClassID() {
- return "ProgressBarUI";
- }
-
- public int getValue() {
- return this.getModel().getValue();
- }
-
- public boolean isBorderPainted() {
- return this.paintBorder;
- }
-
- protected void paintBorder(Graphics g) {
- if (this.isBorderPainted()) {
- super.paintBorder(g);
- }
-
- }
-
- public void removeChangeListener(ChangeListener l) {
- EventListenerList var10000 = super.listenerList;
- Class var10001 = class$com$sun$java$swing$event$ChangeListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$com$sun$java$swing$event$ChangeListener = var10001;
- }
-
- var10000.remove(var10001, l);
- }
-
- public void setBorderPainted(boolean b) {
- this.paintBorder = b;
- ((Component)this).repaint();
- }
-
- public void setMaximum(int n) {
- this.getModel().setMaximum(n);
- }
-
- public void setMinimum(int n) {
- this.getModel().setMinimum(n);
- }
-
- public void setModel(BoundedRangeModel newModel) {
- BoundedRangeModel oldModel = this.getModel();
- if (newModel != oldModel) {
- if (oldModel != null) {
- oldModel.removeChangeListener(this.changeListener);
- this.changeListener = null;
- }
-
- this.barModel = newModel;
- if (newModel != null) {
- this.changeListener = this.createChangeListener();
- newModel.addChangeListener(this.changeListener);
- }
-
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleValue", oldModel == null ? null : new Integer(oldModel.getValue()), newModel == null ? null : new Integer(newModel.getValue()));
- }
-
- this.barModel.setExtent(0);
- ((Component)this).repaint();
- }
-
- }
-
- public void setOrientation(int newOrientation) {
- if (this.orientation != newOrientation) {
- switch (newOrientation) {
- case 0:
- case 1:
- int oldorientation = this.orientation;
- this.orientation = newOrientation;
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleState", oldorientation == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL, this.orientation == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL);
- }
-
- ((Component)this).repaint();
- break;
- default:
- throw new IllegalArgumentException(newOrientation + " is not a legal orientation");
- }
- }
-
- }
-
- public void setUI(ProgressBarUI ui) {
- if (super.ui != ui) {
- super.setUI(ui);
- ((Component)this).repaint();
- }
-
- }
-
- public void setValue(int n) {
- BoundedRangeModel brm = this.getModel();
- int oldValue = brm.getValue();
- brm.setValue(n);
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleValue", new Integer(oldValue), new Integer(brm.getValue()));
- }
-
- }
-
- public void update(Graphics g) {
- ((JComponent)this).paint(g);
- }
-
- public void updateUI() {
- this.setUI((ProgressBarUI)UIManager.getUI(this));
- }
- }
-